package com.ruoyi.common.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;

@Mapper
public interface CommonMapper {

	@Select("SELECT * FROM ${tableName} WHERE id = #{id}")
	HashMap<String, Object> selectDataById(@Param("tableName") String tableName, @Param("id") Long id);

	@Select("SELECT * FROM ${tableName}")
	List<HashMap<String, Object>> selectDatas(@Param("tableName") String tableName);
	@Select("<script>" +
			"SELECT * from ${tableName} " +
			"WHERE ${idKey} in <foreach item='item' index='index' collection='ids' open='(' separator=',' close=')'>" +
			"#{item}" +
			"</foreach>" +
			"</script>")
//	@Select("SELECT * FROM ${tableName} where ${idKey} in (#{ids})")
	List<HashMap<String, Object>> selectDatasByIds(@Param("tableName") String tableName, @Param("idKey") String idKey, @Param("ids") String[] ids);

}
